<!--
 * @Author: 尔尔
 * @Date: 2024-01-06 11:37:19
 * @LastEditors: 尔尔
 * @LastEditTime: 2024-06-14 10:08:54
 * @FilePath: \ERP\src\views\components\previewTemplete\excels.vue
 * @filePurpose:
-->
<template>
	<div v-if="previewType">
		<vue-office-docx :src="previewUrl" @rendered="renderingComplette" style="height: 80vh; width: 100%" v-if="previewType == 'docx'" @error="renderingError"></vue-office-docx>
		<vue-office-excel :src="previewUrl" @rendered="renderingComplette" style="height: 80vh; width: 100%" v-if="previewType == 'xlsx'"></vue-office-excel>
		<!-- <vue-office-pdf :src="previewUrl" v-if="previewType == 'pdf'" style="height: 80vh; width: 100%; overflow-x: auto"></vue-office-pdf> -->
		<pdf :pdfUrl="previewUrl" v-if="previewType == 'pdf'" style="height: 80vh; width: 100%; overflow-x: auto"></pdf>
    <!-- <vue-doc-preview :src="previewUrl" type="doc"></vue-doc-preview> -->
		<!-- word查看详情 -->
		<!-- <div id="wordView" v-html="vHtml"></div> -->

		<!-- <div ref="docpreview"></div>

       <div v-if="previewType == 'doc'" ref="word">
          <iframe  frameborder="0"
                  :src="previewUrl"
                  width='100%'
                  height="100%">
          </iframe>
        </div> -->

		<!-- <iframe :src="iframeSrc" width="100%" height="500" v-if="previewType == 'docx'"></iframe> -->
	</div>
</template>
<script>
import VueOfficeExcel from "@vue-office/excel"
import VueOfficeDocx from "@vue-office/docx"
import VueOfficePdf from "@vue-office/pdf"
import VueDocPreview from "vue-doc-preview"
import mammoth from "mammoth"
import "@vue-office/excel/lib/index.css"
import "@vue-office/docx/lib/index.css"
import pdf from "../previewTemplete/pdfPreview.vue"
export default {
	name: "previewTemplete",
	components: { VueOfficeExcel, VueOfficeDocx, VueOfficePdf, VueDocPreview, pdf },
	props: {
		previewUrl: {
			type: String,
			required: true,
			default: ""
		},
		previewType: {
			type: String,
			required: true,
			default: ""
		}
	},
	data() {
		return {
			iframeSrc: "",
			previews: "",
			vHtml: "",
			wordURL: "" //文件地址，看你对应怎末获取、赋值
			// excelUrl: ""
		}
	},
	created() {
		console.log(this.previewUrl, "excelUrl")
		console.log(this.previewType, "excelUrl")
		// this.convertWordToHtml();
	},
	methods: {
		renderingError() {
			console.log("失败")
		},
		renderingComplette() {
			console.log("完成")
		}
	}
}
</script>
